#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include "colours.h"
//Ossi teki kaiken

const char
*FG_BLACK = "30",
        * FG_GRAY = "1;30",
        * FG_LIGHTGRAY = "37",
        * FG_WHITE = "1;37",
        * FG_RED = "31",
        * FG_LIGHTRED = "1;31",
        * FG_GREEN = "32",
        * FG_LIGHTGREEN = "1;32",
        * FG_BROWN = "33",
        * FG_YELLOW = "1;33",
        * FG_BLUE = "34",
        * FG_LIGHTBLUE = "1;34",
        * FG_PURPLE = "35",
        * FG_FUCSHIA = "1;35",
        * FG_TEAL = "36",
        * FG_CYAN = "1;36",
        * BG_WHITE = "",
        * BG_GRAY = ";47",
        * BG_BLACK = ";40",
        * BG_RED = ";41",
        * BG_GREEN = ";42",
        * BG_BROWN = ";43",
        * BG_BLUE = ";44",
        * BG_PURPLE = ";45",
        * BG_TEAL = ";46";


const wchar_t c_ESC = 27;

void set_colour(const char* fg) {
    putwchar(c_ESC);
    wprintf(L"[%s%sm", fg, BG_BLACK);
}

void set_colour_bg(const char* fg, const char* bg) {
    putwchar(c_ESC);
    wprintf(L"[%s%sm", fg, bg);
}

void reset_colour() {
    putwchar(c_ESC);
    wprintf(L"[0m");
    set_colour_bg(FG_LIGHTGRAY, BG_BLACK);
}

void reset_console() {
    putwchar(c_ESC);
    wprintf(L"[0m");
    putwchar(c_ESC);
    wprintf(L"[2J");

}

void print_colour(wchar_t* text, const char* fg) {

    set_colour(fg);
    wprintf(L"%ls", text);
    reset_colour();

}

void print_colour_bg(wchar_t* text, const char* fg, const char* bg) {
    set_colour_bg(fg, bg);
    wprintf(L"%ls", text);
    reset_colour();
}

void move_cursor(int x, int y) {
    putwchar(c_ESC);
    wprintf(L"[%d;%dH", y, x);
}

void clear_screen() {
    set_colour_bg(FG_WHITE, BG_BLACK);
    for (int i = 1; i <= 24; ++i) {
        move_cursor(1, i);
        for (int j = 1; j <= 80; ++j)
            putwchar(L' ');
    }
    reset_colour();
}
